IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityQueryExtensions Class > GroupBy Method : GroupBy<TSource,TKey,TResult>(IEntityQuery<TSource>,Expression<Func<TSource,TKey>>,Expression<Func<TKey,IEnumerable<TSource>,TResult>>) Method |
'Declaration
<ExtensionAttribute()> Public Overloads Shared Function GroupBy (Of TSource,TKey,TResult)( _ ByVal source As IEntityQuery(Of TSource), _ ByVal keySelector As Expression(Of Func(Of TSource,TKey)), _ ByVal resultSelector As Expression(Of Func(Of TKey,IEnumerable(Of TSource),TResult)) _ ) As IEntityQuery(Of TResult)
'Usage
Dim source As IEntityQuery(Of TSource) Dim keySelector As Expression(Of Func(Of TSource,TKey)) Dim resultSelector As Expression(Of Func(Of TKey,IEnumerable(Of TSource),TResult)) Dim value As IEntityQuery(Of TResult) value = EntityQueryExtensions.GroupBy(Of TSource, TKey, TResult)(source, keySelector, resultSelector)
var mgr = new DomainModelEntityManager(); var query = mgr.Customers.GroupBy(c => c.Country, (s, c) => new { Key=s, Count=c.Count()}); foreach (var group in query) { Console.WriteLine("key = " + group.Key); Console.WriteLine("count=" + group.Count); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2